package com.qwz.example.itreator.impl;

import com.qwz.example.itreator.Iterator;

public class CollectionIteratorImpl implements Iterator {

    private PayManager aggregate;

    public CollectionIteratorImpl(PayManager aggregate) {
        this.aggregate = aggregate;
    }

    private int index = -1;

    public void first() {
        index = 0;
    }

    public void next() {
        if (index < this.aggregate.size()) {
            index += 1;
        }
    }

    public boolean isDone() {
        if (index == this.aggregate.size()) {
            return true;
        }
        return false;
    }

    public Object currentItem() {
        return this.aggregate.get(index);
    }
}
